function myInstanceof(left, right) {
    let proto = Object.getPrototypeOf(left)
    let prototype = right.prototype

    while(proto) {
        if(proto === prototype) {
            return true
        }
        proto = Object.getPrototypeOf(proto)
    }
    return false
}

let c = []
console.log(myInstanceof(c, String))

function createNew() {
    let constructor = [].shift.call(arguments)
    let proto = constructor.prototype

    if (typeof constructor !== "function") {
        console.error("type error");
        return;
    }

    let newObject = Object.create(proto)
    let result = constructor.apply(newObject, arguments)

    let flag = result && (typeof result === "object" || typeof result === "function")

    return flag ? result : newObject
}


let e = createNew(String, 123)
console.log(e, )